package com.scf.contract.controller;

import com.scf.contract.entity.Historyapproval;
import com.scf.contract.service.HistoryapprovalService;
import com.scf.uitl.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author author
 * @create 2021-11-16-14:24
 */
@RestController
@RequestMapping("/historyapproval")
public class HistoryapprovalController {
    @Resource
    HistoryapprovalService historyapprovalService;

    @PostMapping("/addHistoryapproval")
    public ResponseResult addHistoryapproval(@RequestBody Historyapproval historyapproval){
        Historyapproval h = new Historyapproval();
        h.setStep(historyapproval.getStep());
        h.setAgent(historyapproval.getAgent());
        h.setSuggestion(historyapproval.getSuggestion());
        h.setContent(historyapproval.getContent());
        h.setProcessingtime(historyapproval.getProcessingtime());
        historyapprovalService.addHistoryapproval(h);
        ResponseResult responseResult = new ResponseResult();
        responseResult.setCode(200);
        responseResult.setData(null);
        return responseResult;
    }
    @GetMapping("/selectAll")
    public ResponseResult selectAll(){
        List<Historyapproval> historyapprovals = historyapprovalService.selectAll();
        ResponseResult responseResult = new ResponseResult();
        responseResult.setCode(200);
        responseResult.setData(historyapprovals);
        return responseResult;
    }
}
